import request from "."
import type { PageInfo, ApiPageResult, ApiResult } from "@/lib/model"

export default {
    page(dto: ClientSearch) {
        return request.getJson<ClientSearch, ApiPageResult<ClientSearch>>("/client", dto)
    },
    delete(ids: number[]) {
        return request.deleteJson<number[], ApiResult>("/client", ids)
    },
    save(dto: ClientItem) {
        return request.postJson<ClientItem, ApiResult>("/client", dto)
    },
}

export interface ClientSearch extends PageInfo {
    name?: string
}


export interface ClientItem {
    "id"?: number
    "enabled"?: boolean
    "clientId"?: string
    "protocolType"?: string
    "clientSecrets"?: {
        "id"?: number,
        "description"?: string
        "value"?: string
        "expiration"?: string
        "type"?: string
        "created"?: string
        "clientId"?: 0,
        "client"?: string
    }[]
    "requireClientSecret"?: boolean
    "clientName"?: string
    "description"?: string
    "clientUri"?: string
    "logoUri"?: string
    "requireConsent"?: boolean
    "allowRememberConsent"?: boolean
    "alwaysIncludeUserClaimsInIdToken"?: boolean
    "allowedGrantTypes"?: {
        "id"?: number
        "grantType"?: string
        "clientId"?: number
    }[]
    "requirePkce"?: boolean,
    "allowPlainTextPkce"?: boolean
    "requireRequestObject"?: boolean
    "allowAccessTokensViaBrowser"?: boolean
    "redirectUris"?: {
        "id"?: number
        "redirectUri"?: string
        "clientId"?: number
    }[]
    "postLogoutRedirectUris"?: {
        "id"?: number
        "postLogoutRedirectUri"?: string
        "clientId"?: number
    }[]
    "frontChannelLogoutUri"?: string
    "frontChannelLogoutSessionRequired"?: boolean
    "backChannelLogoutUri"?: string
    "backChannelLogoutSessionRequired"?: boolean
    "allowOfflineAccess"?: boolean
    "allowedScopes"?: {
        "id"?: number
        "scope"?: string
        "clientId"?: number
    }[]
    "identityTokenLifetime"?: number
    "allowedIdentityTokenSigningAlgorithms"?: string
    "accessTokenLifetime"?: number
    "authorizationCodeLifetime"?: number
    "consentLifetime"?: number
    "absoluteRefreshTokenLifetime"?: number
    "slidingRefreshTokenLifetime"?: number
    "refreshTokenUsage"?: number
    "updateAccessTokenClaimsOnRefresh"?: boolean
    "refreshTokenExpiration"?: number
    "accessTokenType"?: number
    "enableLocalLogin"?: boolean,
    "identityProviderRestrictions"?: {
        "id"?: number
        "provider"?: string
        "clientId"?: number
    }[]
    "includeJwtId"?: boolean
    "claims"?: {
        "id"?: number
        "type"?: string
        "value"?: string
        "clientId"?: number
    }[]
    "alwaysSendClientClaims"?: boolean
    "clientClaimsPrefix"?: string
    "pairWiseSubjectSalt"?: string
    "allowedCorsOrigins"?: {
        "id"?: number
        "origin"?: string
        "clientId"?: number
    }[],
    "properties"?: {
        "id"?: number
        "key"?: string
        "value"?: string
        "clientId"?: number
    }[]
    "created"?: string
    "updated"?: string
    "lastAccessed"?: string
    "userSsoLifetime"?: number
    "userCodeType"?: string
    "deviceCodeLifetime"?: number
    "nonEditable"?: boolean
}